#include "Comm.hpp"
int main()
{
    char buffer[1024];
    SetNonblock(0); // 设置非阻塞
    while (true)
    {
        ssize_t s = read(0, buffer, sizeof(buffer) - 1);
        if (s > 0)
        {
            buffer[s] = 0;
            cout << "echo# " << buffer << endl;
        }
        else
        {
            if (errno == EWOULDBLOCK || errno == EAGAIN)
            {
                cout << "IO条件不就绪, 下次再试下" << endl;
                sleep(1);
                continue;
            }
            // 被信号中断
            else if (errno == EINTR)
            {
                continue;
            }
            else
            {
                cout << "读取错误..." << endl;
                sleep(1);
            }
        }
    }
    return 0;
}